package numericalSim;
import simulationSupport.*;

public class IndividualModel {
	
	private char gender;
	private int age;
	private double weight;
	private double length;
	private double speed;
	private double catchability;
	private double growthRate;
	private int maxgrowthyears;
	private int ID;
	
	private IndividualModel(int id, char g,double growthrate,int mgy)
	{
		age = 0;		//age on months
		gender = g;
		growthRate = growthrate;
		weight = 0.5;
		length = 10;		
		speed = 10 + weight/10 + length/12 ; //Base 10 kmh , plus bonuses
		catchability = weight * length * speed;
		maxgrowthyears = mgy;
		ID = id;
	}
	private IndividualModel (int mgy,int id,char gender,double weigth, double length)
	{
		this.age = 12;
		this.gender = gender;
		this.growthRate = WorldModel.minWeigth + 4*WorldModel.increment;
		this.ID=id;
		this.length = length;
		this.maxgrowthyears = mgy;
		this.weight = weigth;
		this.speed = 10 + weight/10 + length/12 ; 
	}
	
	public static IndividualModel birthFish(int mgy,int id,double minW,double incr)
	{
		char gender;
		if(Math.random()>0.5){gender = 'M';}
		else{gender = 'F';}
		double[] prob = {0.02,0.03,0.05,0.15,0.5,0.15,0.05,0.03,0.02};
		ParamRandom r = new ParamRandom(minW, incr, prob);
		double gr = r.getRandomedTarget();
		IndividualModel ret = new IndividualModel(id,gender,gr,mgy);
		return ret;
	}
	
	public static IndividualModel addFish(int mgy,int id,char gender,double weigth,double length)
	{
		return new IndividualModel(mgy, id, gender, weigth, length);
	}
	
	public char getGender() {
		return gender;
	}


	public void increaseAge() {
		this.age++;
		if(age <= maxgrowthyears)			
		{
			this.increaseWeight();
			this.increaseLength();
			speed = 10 + weight/10 + length/12 ;
		}
	}


	public int getAge() {
		return age;
	}


	public void increaseWeight() {
		weight = weight + 7*growthRate;
	}


	public double getWeight() {
		return weight;
	}


	public void increaseLength() {
		length = length + 10*growthRate;
	}


	public double getLength() {
		return length;
	}

	public double getSpeed() {
		return speed;
	}

	public double getCatchability() {
		return catchability;
	}

	public double getGrowthRate() {
		return growthRate;
	}

	public int getID() {
		return ID;
	}

	public int getMaxgrowthyears() {
		return maxgrowthyears;
	}
	
	

}
